﻿namespace QLPhongKham.Access.VienPhi
{
    using ConfigDatabase.Class;
    using Npgsql;
    using QLPhongKham.Access;
    using QLPhongKham.BaseClass.Duoc;
    using QLPhongKham.BaseClass.VienPhi;
    using System;
    using System.Data;

    public class VDMVienPhi
    {
        private ConnectDatabase _condata;
        private NpgsqlConnection _conn;
        private General _xuli;

        public VDMVienPhi()
        {
            this._condata = new ConnectDatabase();
            this._xuli = new General(this._condata);
        }

        public VDMVienPhi(ConnectDatabase condata)
        {
            this._condata = condata;
            this._xuli = new General(this._condata);
        }

        public DataTable f_loaddata_dmvienphi(long id, int thuoc)
        {
            object obj2;
            string sql = "select " + dtoDDMDuocPham.columnID + "," + dtoDDMDuocPham.columnMA + "," + dtoDDMDuocPham.columnTEN + "," + dtoDDMDuocPham.columnDVT + ",0 as dongia,1 as thuoc from " + this._xuli.pSchema + "." + dtoDDMDuocPham.tableName + " where 1=1 ";
            if (thuoc == 2)
            {
                sql = sql + " and 1=2";
            }
            if (id != 0L)
            {
                obj2 = sql;
                sql = string.Concat(new object[] { obj2, " and ", dtoDDMDuocPham.columnID, "=", id });
            }
            string str2 = sql;
            sql = str2 + " union all select " + dtovpDMVienPhi.columnID + "," + dtovpDMVienPhi.columnMA + "," + dtovpDMVienPhi.columnTEN + "," + dtovpDMVienPhi.columnDVT + "," + dtovpDMVienPhi.columnDONGIA + " as dongia,0 as thuoc from " + this._xuli.pSchema + "." + dtovpDMVienPhi.tableName;
            if (thuoc == 1)
            {
                sql = sql + " and 1=2";
            }
            if (id != 0L)
            {
                obj2 = sql;
                sql = string.Concat(new object[] { obj2, " and ", dtoDDMDuocPham.columnID, "=", id });
            }
            return this._xuli.f_Get_dulieu(sql).Tables[0];
        }
    }
}

